
#ifndef __STM32_UTIL_H__
#define __STM32_UTIL_H__


/* Includes ------------------------------------------------------------------*/
#include "data_type.h"

/* Exported types ------------------------------------------------------------*/
enum
{
	eAFCLK_NONE=0,
	eAFCLK_AHB1,
	eAFCLK_AHB2,
	eAFCLK_APB1,
	eAFCLK_APB2,
	eAFCLK_MAX,
};
typedef struct
{
	uint32_t			AHB1Clk;
	GPIO_InitTypeDef	Gpio;
	GPIO_TypeDef*		Port;

	uint8_t				AFType;
	uint32_t			AFClk;
	uint16_t			AFPinSrc;
	uint8_t				AF;
} GPIO_INIT;

typedef struct
{
	uint8_t				PortSrc;
	uint8_t				PinSrc;
	EXTI_InitTypeDef	Exti;
	NVIC_InitTypeDef	Nvic;
} EXTI_INIT;

typedef struct
{
	USART_TypeDef*		Port;
	USART_InitTypeDef	Uart;
	NVIC_InitTypeDef	Nvic;
} UART_INIT;

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/

/* Exported functions ------------------------------------------------------- */
time_t Util_GetBuildTime(void);

void Util_GpioInit(GPIO_INIT *gis, uc32 count);
void Util_ExtiInit(EXTI_INIT *uis, uc32 count);
void Util_UartInit(UART_INIT *uis, uc32 count);

u32 Util_IsResetWWDG(void);
void Util_ResetWWDG(void);

u8 Util_BoardAddr(void);
u8 Util_FirmwareUpdate(uc32 uAddr, uc16 uTotalSize);

void Util_uDelay(uc32 usec);
void Util_mDelay(uc32 msec);


/* External variables --------------------------------------------------------*/


#endif /*__STM32_UTIL_H__*/
